package org.erepublik.company.controllers;

import java.util.Arrays;

import org.erepublik.company.PriceIndex;
import org.erepublik.company.searchCriteria.EHouseChartCriteria;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("/housePricesHistory.html")
public class HousePricesHistoryController extends AbstractController  {

    
    @RequestMapping(method = RequestMethod.GET)
    public String showForm(ModelMap model) {
        fillModelMap(model);
        PriceIndex[] prices = countryDataService.getPricesIndex("house", EHouseChartCriteria.WELLNESS);
        Arrays.sort(prices);
        model.addAttribute("prices", prices);

        return "housePricesHistory";
    }
    
    
    @RequestMapping(method = RequestMethod.POST)
    public String showList(ModelMap model) {
        fillModelMap(model);
        PriceIndex[] prices = countryDataService.getPricesIndex("house", EHouseChartCriteria.WELLNESS);
        Arrays.sort(prices);
        
        model.addAttribute("prices", prices);
        return "housePricesHistory";
    }
    

    
}
